package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.util.List;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import org.come.model.Eshop;

import com.tool.btn.TaoBaoBtn;
import com.tool.tcpimg.UIUtils;

/**
 * 商城限购面板
 * <p>
 * Title : QuotaJpanel
 * </p>
 * 
 * @author : HGC
 * @date : 2019年7月17日 上午9:40:21
 * @version : 1.0.0
 */
public class QuotaJpanel extends JPanel {

	/** 7-18-HGC-start */
	// private String[] menuName = { "换送好礼", "冲级必备", "显示折扣" };
	// private TaoBaoBtn[] menuBtn = new TaoBaoBtn[3];
	/**
	 * 兑换好礼exchangeMenuBtn<br>
	 * 冲级必备levelMenuBtn<br>
	 * 显示折扣discountMenuBtn<br>
	 */
	private TaoBaoBtn exchangeMenuBtn, levelMenuBtn, discountMenuBtn;
	/** 7-18-HGC-end */


	private TaoBaoBtn btnhp,// 首页
			btnep,// 末页
			btnsyy,// 上一页
			btnxyy;// 下一页

	private int maxPage = 1; // 最大页码
	private int nowpage = 1; // 当前页数
	//
	private static JLabel labpage; // 放置当前页数和总页数

	private RechargeLeftGoodsJpanel[] imageJpanel = new RechargeLeftGoodsJpanel[9]; // 展充值详细信息息

	public QuotaJpanel() {

		this.setPreferredSize(new Dimension(682, 445));
		this.setLayout(null);
		this.setOpaque(false);
		this.setBackground(UIUtils.Color_BACK);

		// 放置当前页数和总页数
		labpage = new JLabel(nowpage + "/" + maxPage, SwingConstants.CENTER);
		labpage.setForeground(Color.white);
		labpage.setBounds(335 - 24, 378 + 14, 58, 16);
		labpage.setFont(UIUtils.TEXT_FONT1);
		this.add(labpage);

		// 首页
		btnhp = new TaoBaoBtn("inkImg/hongmu/2/homepage.png", 1, "", 50);
		btnhp.setBounds(279 - 26, 378 + 13, 34, 17);
		this.add(btnhp);

		// 上一页
		btnsyy = new TaoBaoBtn("inkImg/hongmu/2/29_png.button.btn_8.png", 1, "", 51);
		btnsyy.setBounds(315 - 26, 378 + 12, 19, 20);
		this.add(btnsyy);

		// 下一页
		btnxyy = new TaoBaoBtn("inkImg/hongmu/2/36_png.button.btn_7.png", 1, "", 52);
		btnxyy.setBounds(397 - 24, 378 + 12, 19, 20);
		this.add(btnxyy);

		// 末页
		btnep = new TaoBaoBtn("inkImg/hongmu/2/endpage.png", 1, "末页", 53);
		btnep.setBounds(416 - 24, 378 + 13, 34, 17);
		this.add(btnep);

		
		// 展示的特效信息
		for (int i = 0; i < imageJpanel.length; i++) {
			int row = i % 3;
			int col = i / 3;
			imageJpanel[i] = new RechargeLeftGoodsJpanel(null);
			imageJpanel[i].setBounds(54 + row * 205, 52 + col * 100, 200, 90);
			this.add(imageJpanel[i]);
		}
		/** 7-18-HGC-start */
		// for (int i = 0; i < menuBtn.length; i++) {
		// menuBtn[i] = new TaoBaoBtn("skin/8100226/button/3.png", 1, menuName[i], i +
		// 30, this);
		// menuBtn[i].setBounds(54 + i * 77, 15, 75, 26);
		// menuBtn[i].setOpaque(false);
		// this.add(menuBtn[i]);
		// }
		// try {
		// menuBtn[0].setIcons(CutButtonImage.cuts("skin/8100226/button/4.png"));
		// } catch (Exception e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// }
		getExchangeMenuBtn();
		getLevelMenuBtn();
		getDiscountMenuBtn();
		/** 7-18-HGC-end */
	}

	/** 更换展示的商品 */
	public void changeShopGoodsView(List<Eshop> eshopList) {
		for (int i = 0; i < imageJpanel.length; i++) {
			imageJpanel[i].clearWindow();
		}
		maxPage = eshopList.size() % 9 == 0 ? eshopList.size() / 9 : eshopList.size() / 9 + 1;
		labpage.setText(nowpage + "/" + maxPage);
		int num = 0;
		for (int i = (nowpage - 1) * 9; i < 9 * nowpage; i++) {
			if (eshopList.size() <= i) {
				break;
			}
			imageJpanel[num].addEshopMessage(eshopList.get(i));
			num++;
		}
	}

	public static JLabel getLabpage() {
		return labpage;
	}

	public static void setLabpage(JLabel labpage) {
		QuotaJpanel.labpage = labpage;
	}

	public TaoBaoBtn getBtnhp() {
		return btnhp;
	}

	public void setBtnhp(TaoBaoBtn btnhp) {
		this.btnhp = btnhp;
	}

	public TaoBaoBtn getBtnep() {
		return btnep;
	}

	public void setBtnep(TaoBaoBtn btnep) {
		this.btnep = btnep;
	}

	public TaoBaoBtn getBtnsyy() {
		return btnsyy;
	}

	public void setBtnsyy(TaoBaoBtn btnsyy) {
		this.btnsyy = btnsyy;
	}

	public TaoBaoBtn getBtnxyy() {
		return btnxyy;
	}

	public void setBtnxyy(TaoBaoBtn btnxyy) {
		this.btnxyy = btnxyy;
	}

	public RechargeLeftGoodsJpanel[] getImageJpanel() {
		return imageJpanel;
	}

	public void setImageJpanel(RechargeLeftGoodsJpanel[] imageJpanel) {
		this.imageJpanel = imageJpanel;
	}

	public int getMaxPage() {
		return maxPage;
	}

	public void setMaxPage(int maxPage) {
		this.maxPage = maxPage;
	}

	public int getNowpage() {
		return nowpage;
	}

	public void setNowpage(int nowpage) {
		this.nowpage = nowpage;
	}

	

	public TaoBaoBtn getExchangeMenuBtn() {
		if (exchangeMenuBtn == null) {
			exchangeMenuBtn = new TaoBaoBtn("inkImg/hongmu/2/二级选项卡_商城_限购_赠送好礼_选中_w100,h78.png", 1, "", 30, this);
			exchangeMenuBtn.setBounds(54 + 0 * 102, 15, 100, 26);
			this.add(exchangeMenuBtn);
		}
		return exchangeMenuBtn;
	}

	public void setExchangeMenuBtn(TaoBaoBtn exchangeMenuBtn) {
		this.exchangeMenuBtn = exchangeMenuBtn;
	}

	public TaoBaoBtn getLevelMenuBtn() {
		if (levelMenuBtn == null) {
			levelMenuBtn = new TaoBaoBtn("inkImg/hongmu/2/二级选项卡_商城_限购_冲级必备_未选中_w100,h78.png", 1, "", 31, this);
			levelMenuBtn.setBounds(54 + 1 * 102, 15, 100, 26);
			this.add(levelMenuBtn);
		}
		return levelMenuBtn;
	}

	public void setLevelMenuBtn(TaoBaoBtn levelMenuBtn) {
		this.levelMenuBtn = levelMenuBtn;
	}

	public TaoBaoBtn getDiscountMenuBtn() {
		if (discountMenuBtn == null) {
			discountMenuBtn = new TaoBaoBtn("inkImg/hongmu/2/二级选项卡_商城_限购_显示折扣_未选中_w100,h78.png", 1, "", 32, this);
			discountMenuBtn.setBounds(54 + 2 * 102, 15, 100, 26);
			this.add(discountMenuBtn);
		}
		return discountMenuBtn;
	}

	public void setDiscountMenuBtn(TaoBaoBtn discountMenuBtn) {
		this.discountMenuBtn = discountMenuBtn;
	}

}
